<?php

if ( empty($paramsArr['tid']) )
	showMsg('Không có dữ liệu !','ex','center');
else
{
	$template->set_filenames(array(
		'body'	=> 'view_article_list.tpl'
	));
	
	$sql = "SELECT * FROM pctroubleshooting_article WHERE tid=" . $paramsArr['tid'] . " AND tmp=0";
	$rs = $link->execute($sql);
	
	if ( !$rs->EOF )
	{
		$current_page = (!get_magic_quotes_gpc()) ? addslashes(@$_GET['page']) : intval(@$_GET['page']);
		if ( $current_page <= 0 )
			$current_page = 1;
		
		$s_record = ($current_page-1) * $info['list_page_size'];
		$e_record = $s_record + $info['list_page_size'];

		if ( !isset($_GET['page']) )
			$strAction = $_SERVER['QUERY_STRING'];
		else
			$strAction = substr($_SERVER['QUERY_STRING'],0,strlen($_SERVER['QUERY_STRING'])- strlen($current_page)-6 );

		$pg = ShowPaging(&$rs, $info['list_page_size'], basename($_SERVER['SCRIPT_FILENAME']) . '?' . $strAction, $current_page,5,true,true,false,true);

		$template->assign_vars(array(
			'_HEADER'		=> showHeader('HỎI - ĐÁP'),
			'_QUESTIONER'	=> $lang['l_pc_questioner'],
			'_QUESTIONER_'	=> $rs->fields('questioner'),
			'_QUESTION'		=> $lang['l_pc_question'],
			'_ANSWERER'		=> $lang['l_pc_answerer'],
			'_ANSWER'		=> $lang['l_pc_answer'],
			'_VIEW_DETAIL'	=> $lang['l_pc_viewdetail'],
			'_PAGING'		=> $pg
		));
		
		$stt = 0;
		while ( !$rs->EOF && $stt < $info['list_page_size'] )
		{
			$stt++;
			$template->assign_block_vars('detail',array(
				'questioner'	=> $rs->fields('questioner'),
				'question'		=> $rs->fields('question_' . $_SESSION['cur_lang']),
				'answerer'		=> $rs->fields('answerer'),
				'answer'		=> $rs->fields('answer_' . $_SESSION['cur_lang']),
				'_QUESTION_DATE'=> toVNDate($rs->fields('question_date')),
				'_VIEW_DETAIL_LINK'=> setURLParams('act=dyn&mod=PCTroubleshooting&f=view_detail_item&id='.$rs->fields('Id'))
			));
			
			$rs->MoveNext();
		}
		
	}
	else
		showMsg('Chưa có bài viết !','info','center');
	
	$template->pparse('body');
}

?>